<template>
    <div class="e-form">
        <div class="title">{{ formData.projectName }}公开招标</div>
        <div class="tabs">
            <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="招标包件信息"
                    name="package"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="企业主要业绩"
                    name="enterprise"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane label="资质信息" name="quaInfo" :disabled="clickTabFlag"></el-tab-pane>
                <div>
                    <div id="baseInfoCon" class="con">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form
                                ref="form"
                                :model="formData"
                                label-width="170px"
                                :rules="rules"
                            >
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="统一社会信用代码" prop="unitCode">
                                            <el-input
                                                v-model="formData.unitCode"
                                                placeholder="请先输入统一社会信用代码"
                                                @blur="unitCodeBlur(formData.unitCode)"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="投标单位" prop="unitName">
                                            <el-input
                                                v-model="formData.unitName"
                                                :disabled="unitCodeState"
                                                :maxlength="50"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="法人代表" prop="legalRepresentative">
                                            <el-input
                                                v-model="formData.legalRepresentative"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item
                                            label="注册资本（万元）"
                                            prop="registerCaptial"
                                        >
                                            <el-input
                                                v-model.number="formData.registerCaptial"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="资质等级">
                                            <el-input
                                                v-model="formData.qualificationLevelName"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="联系电话（手机）" prop="telephone">
                                            <el-input
                                                v-model="formData.telephone"
                                                :disabled="unitCodeState && unitCodeState2"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="传真">
                                            <el-input
                                                v-model="formData.fax"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="邮箱" prop="email">
                                            <el-input
                                                v-model="formData.email"
                                                :disabled="unitCodeState"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="纳税类别">
                                            <el-select
                                                v-model="formData.taxpayerType"
                                                placeholder="请选择"
                                                :disabled="unitCodeState"
                                            >
                                                <el-option
                                                    v-for="item in options2.taxpayerType"
                                                    :key="item.value"
                                                    :label="item.value"
                                                    :value="item.value"
                                                    :disabled="item.disabled"
                                                >
                                                </el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="是否境外单位：">
                                            <el-checkbox
                                                v-model="formData.isAbroad"
                                                :true-label="1"
                                                :false-label="0"
                                                :disabled="unitCodeState"
                                                @change="changeIsAbroad(formData.isAbroad)"
                                            ></el-checkbox>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row style="align-items: stretch">
                                    <el-col :span="24">
                                        <el-form-item label="地址：">
                                            <SelectAddr
                                                v-model="formData.registerAddress"
                                                lazy
                                                showCountry
                                                style="width: 100%"
                                                :disabled="unitCodeState"
                                            ></SelectAddr>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <!-- <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="作废原因" >
                                            <span>{{ formData.nullifyReason }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="作废人" >
                                            <span>{{ formData.nullifyCreator }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="作废时间" >
                                            <span>{{ formData.nullifyCreated }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row> -->
                            </el-form>
                        </div>
                    </div>

                    <div id="packageCon" class="con e-table">
                        <div class="tabs-title" id="package">
                            <!-- <span style="color: red">*</span> -->
                            招标包件信息
                        </div>
                        <el-table
                            :data="packageTableData"
                            border
                            style="width: 100%"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('packageTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column type="selection" width="55"> </el-table-column>
                            <el-table-column width="200" prop="itemNo" label="包件号">
                            </el-table-column>
                            <el-table-column width="200" prop="name" label="包件名称">
                            </el-table-column>
                            <el-table-column
                                min-width="150"
                                prop="priceLimit"
                                label="招标最高限价（元）"
                            >
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="enterpriseCon" class="con e-table">
                        <div class="tabs-title" id="enterprise">
                            <!-- <span style="color: red">*</span> -->
                            企业主要业绩
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="enterpriseAdd(enterpriseTableData)"
                                v-if="!unitCodeState || !unitCodeState2"
                                >新增</el-button
                            >
                            <el-button
                                class="btn-delete"
                                @click="deleteTableRow('enterpriseTableData')"
                                v-if="!unitCodeState || !unitCodeState2"
                                >删除</el-button
                            >
                            <!-- <el-button @click="tableDel('enterprise')">删除行</el-button> -->
                        </div>
                        <el-table
                            :data="enterpriseTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('enterpriseTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column width="100" label="操作" type="selection">
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="contractName"
                                label="合同名称"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.contractName"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="projectName"
                                label="项目名称"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.projectName"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="contractAmount"
                                label="合同金额（元）"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.contractAmount"
                                        placeholder="请输入内容"
                                        v-enterJustFloat
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="workContent"
                                label="所承担工作内容"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.workContent"
                                        placeholder="请输入内容"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="startTime" label="开工时间">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.startTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        @blur="timeBlur(row)"
                                    >
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="endTime" label="竣工时间">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.endTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        :picker-options="pickerOptions(row)"
                                    >
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="personInCharge" label="项目负责人">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.personInCharge"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="witness"
                                label="业绩证明人"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.witness"
                                        placeholder="请输入内容"
                                        :maxlength="50"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="witnessPhone"
                                label="证明人电话"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.witnessPhone"
                                        placeholder="请输入内容"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" prop="proveFile" label="证明附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                        >
                                            <el-button size="mini" type="primary">上传</el-button>
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a
                                                    :href="row.filePath"
                                                    target="_blank"
                                                    v-if="row.filePath"
                                                    >{{ row.fileName }}</a
                                                >
                                                <a v-else>{{ row.fileName }}</a>
                                            </div>
                                            <!-- 正好没返path，没附件id反正也删不掉 -->
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.filePath"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="quaInfoCon" class="con e-table">
                        <div class="tabs-title" id="quaInfo">
                            <!-- <span style="color: red">*</span> -->
                            资质信息
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="quaInfoAdd(quaInfoTableData)"
                                v-if="!unitCodeState"
                                >新增</el-button
                            >
                            <el-button
                                class="btn-delete"
                                @click="deleteTableRow('quaInfoTableData')"
                                v-if="!unitCodeState"
                                >删除</el-button
                            >
                            <!-- <el-button type="success">下载</el-button> -->
                            <!-- <el-button @click="tableDel('quaInfo')">删除行</el-button> -->
                        </div>
                        <el-table
                            :data="quaInfoTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('quaInfoTableData', $event)"
                            :max-height="$store.state.tableHeight"
                            ref="table"
                            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column width="100" label="操作" type="selection">
                            </el-table-column>
                            <el-table-column width="150" prop="certificateType" label="证书类型">
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <el-select
                                            v-model="row.certificateType"
                                            placeholder="请选择"
                                            @change="certificateTypeChange($event, row)"
                                        >
                                            <el-option
                                                v-for="item in options2.certificateType2"
                                                :key="item"
                                                :label="item"
                                                :value="item"
                                            >
                                            </el-option>
                                        </el-select>
                                    </div>
                                    <span v-else>{{ row.certificateType }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="certificateNo" label="证书编号">
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <el-input
                                            v-model="row.certificateNo"
                                            placeholder="请输入内容"
                                            :disabled="row.certificateType === '营业执照'"
                                        ></el-input>
                                    </div>
                                    <span v-else>{{ row.certificateNo }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="certificateGrade"
                                label="主营范围/资质等级"
                            >
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <span>
                                            <el-input
                                                v-if="
                                                    row.certificateType === '营业执照' ||
                                                    row.certificateType === '资质证书'
                                                "
                                                readonly
                                                v-model="row.certificateGrade"
                                                placeholder="请选择"
                                            >
                                                <i
                                                    slot="suffix"
                                                    class="el-icon-document-copy"
                                                    @click="onSelect(row)"
                                                    style="cursor: pointer"
                                                ></i>
                                            </el-input>
                                        </span>
                                    </div>
                                    <span v-else>{{ row.certificateGrade }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="startTime" label="有效开始日期">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.startTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        @blur="timeBlur(row)"
                                    >
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" prop="endTime" label="有效结束日期">
                                <template slot-scope="{ row }">
                                    <span v-if="row.frontState === 1">
                                        <el-date-picker
                                            v-model="row.endTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            :picker-options="pickerOptions(row)"
                                            style="width: 150px"
                                        >
                                        </el-date-picker>
                                        <el-button
                                            class="btn-blue"
                                            style="margin-left: 10px"
                                            size="mini"
                                            @click="forever(row, 'endTime')"
                                            >永久</el-button
                                        >
                                    </span>
                                    <span v-else>{{ row.endTime }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="fileName" label="文件名">
                            </el-table-column>
                            <el-table-column width="150" prop="fileSize" label="大小">
                                <template slot-scope="{ row }" v-if="row.fileSize">
                                    {{ bytesToSize(row.fileSize) }}
                                </template>
                            </el-table-column>
                            <el-table-column width="200" prop="upTime" label="上传时间">
                            </el-table-column>
                            <el-table-column width="250" label="附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                        >
                                            <el-button
                                                size="mini"
                                                type="primary"
                                                v-if="!unitCodeState"
                                                >上传</el-button
                                            >
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a :href="row.filePath" target="_blank">{{
                                                    row.fileName
                                                }}</a>
                                            </div>
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.fileName && !unitCodeState"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
                <div style="font-weight: bold">
                    承诺：我代表公司承诺，上述信息正确、合法有效、若招标人（发起人）在招标过程中或中标后发现上述信息存在虚假、我们承诺承袒由此造成的所有责任（包括但不限于无条件故弃中标）。
                </div>
            </el-tabs>
        </div>

        <div class="buttons">
            <el-button type="primary" class="btn-blue" @click="submit">提交</el-button>
            <el-button @click="reset">重置</el-button>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <el-dialog
            :title="dialogTitle"
            :visible.sync="dialogVisible"
            width="50%"
            style="padding: 50px"
        >
            <span>
                <el-tree
                    :props="props"
                    :load="loadNode"
                    lazy
                    show-checkbox
                    style="margin-top: 20px"
                    @check-change="treeCheckChange"
                    :key="treeKey"
                >
                </el-tree>
            </span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="diaLogSubmit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
// import ComTreeTable from '@/templates/table/treeTable.vue'
// import ComTreeFile from '@/templates/table/treeFile.vue'
// import ComPagination from '@/components/pagination/pagination.vue'
import enrollRequest from '@/api/tender/enroll.js'
import equipmentProcurementRequest from '@/api/tender/equipmentProcurement.js'
import commonRequest from '@/api/tender/common.js'
import call from '@/api/OutsourcingartyAdmin/getAllType.js'
import ossRequest from '@/api/oss/oss.js'
import { mapState } from 'vuex'
import SelectAddr from '@/components/common/addrComp'
// import { random19Num } from '@/utils/common'
import { ip } from '@/utils/request'
import { uidBuilder } from '@/api/base/uid.js'
import { bytesToSize } from '@/utils/common'
import openBiddingRequest from '@/api/tender/openBidding.js'

export default {
    data () {
        var isMobileNumber = (rule, value, callback) => {
            if (!value) {
                return new Error('请输入电话号码')
            } else {
                const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
                const isPhone = reg.test(value)
                value = Number(value) //转换为数字
                if (typeof value === 'number' && !isNaN(value)) {
                    //判断是否为数字
                    value = value.toString() //转换成字符串
                    if (value.length < 0 || value.length > 12 || !isPhone) {
                        //判断是否为11位手机号
                        callback(new Error('手机号码格式如:138xxxx8754'))
                    } else {
                        callback()
                    }
                } else {
                    callback(new Error('请输入电话号码'))
                }
            }
        }
        var isEmail = (rule, value, callback) => {
            if (!value) {
                callback()
            } else {
                const reg =
                    /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
                const email = reg.test(value)
                if (!email) {
                    callback(new Error('邮箱格式如:admin@163.com'))
                } else {
                    callback()
                }
            }
        }
        return {
            unitCodeState: true, // 信用代码是否通过状态，true全禁止，false可编辑
            unitCodeState2: true, // 信用代码通过，代理人、固定电话、联系电话、企业主要业绩可以编辑
            // 基础信息
            formData: {
                abandondeExplain: '',
                abandonedReason: '',
                abandonedTime: '',
                abandonedUser: '',
                abandonedUserId: '',
                applyUnit: '',
                applyUnitId: '',
                billId: '',
                email: '',
                enrollTime: '',
                fax: '',
                fixedTelephone: '',
                gmtCreate: '',
                gmtModified: '',
                legalRepresentative: '',
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: '',
                nullifyDescription: '',
                nullifyReason: '',
                orgId: '',
                orgName: '',
                outsourceType: [],
                packageIds: '',
                packageName: '',
                projectName: '',
                proxyUser: '',
                registerAddress: '',
                registerCaptial: 0,
                state: 0,
                taxpayerType: '',
                telephone: '',
                tenderApplyId: '',
                tenderApplyNo: '',
                tenderType: 0,
                unitCode: '',
                unitName: '',
                workId: '',
                zipCode: '',
                qualificationLevelName: '',
                isAbroad: 0
            },
            // 包件列表
            packageTableData: [],
            // 包件名字
            // packageName: '',
            // 资质信息
            quaInfoTableData: [],
            // 历史业绩
            enterpriseTableData: [],
            upData: {
                bucketName: 'tender',
                relationId: ''
            },
            ip: ip + '/oss/uploader',
            selection: {},
            tenderData: {}, //基础招标信息
            managerTableData: [],
            attachTableData: [],
            // enterpriseFormData: [],
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            tableData: [],
            value: '',
            // el-input: '',
            test: '',
            selectData: [],
            selectTableColumnAttr: [
                {
                    label: '单据编号',
                    prop: 'billNo'
                },
                {
                    label: '拟招标项目名称',
                    prop: 'tenderName'
                },
                {
                    label: '单据日期',
                    prop: 'gmtCreate'
                },
                {
                    label: '单据机构名称',
                    prop: 'orgName'
                }
            ],
            selectTableColumnWidth: {
                leftWidth: '150',
                rightWidth: '100'
            },
            selectDataPagination: {},
            fileList4: [],
            isIndeterminate: true,
            checkAll: false, //是否全选
            typeList: [],
            payTaxesTypeList: [],
            pickerOptions: row => {
                return {
                    disabledDate (time) {
                        return time.getTime() < new Date(row.startTime).getTime() + 86400000
                    }
                }
            },
            rules: {
                unitCode: {
                    required: true,
                    type: 'string',
                    message: '请输入社会信用代码'
                },
                unitName: { required: true, type: 'string', message: '请输入投标单位' },
                legalRepresentative: {
                    required: true,
                    type: 'string',
                    message: '请输入法人代表'
                },
                registerCaptial: {
                    required: true,
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                telephone: { required: true, validator: isMobileNumber, trigger: 'blur' },
                email: { validator: isEmail, trigger: 'blur' },
                certifiedConstructorNum: { type: 'number', message: '请输入数字', trigger: 'blur' },
                middlePosition: { type: 'number', message: '请输入数字', trigger: 'blur' },
                certificateScene: { type: 'number', message: '请输入数字', trigger: 'blur' },
                middleTechnology: { type: 'number', message: '请输入数字', trigger: 'blur' },
                safetyNum: { type: 'number', message: '请输入数字', trigger: 'blur' },
                socialNum: { type: 'number', message: '请输入数字', trigger: 'blur' }
            },
            dialogVisible: false,
            dialogTitle: '',
            props: {
                label: 'kvValue',
                // children: 'zones',
                isLeaf: 'isLeaf'
            },
            treeCheckSet: new Set(),
            row: null, //资质信息 主营范围/资质等级 回调弹窗保存的当前row
            treeKey: 0
        }
    },
    watch: {
        'formData.outsourceValue' (val) {
            console.log()
            val[val.findIndex(item => item === '施工合作')] = '施工分包'
        }
    },
    computed: {
        ...mapState({
            options2: state => state.biddingApplication.openDictionaries,
            options: state => state.biddingApplication.dictionaries
        }),
        // ...mapState({
        //     options: state => state.biddingApplication.openDictionaries
        // }),
        ...mapState(['userInfo']),
        tenderId () {
            // return this.formData.tenderApplyId
            return this.$route.query.tenderId || this.$route.query.billid //假数据
        },
        billId () {
            return this.$route.query.billId || this.$route.query.billid
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        // ComTreeTable,
        // ComTreeFile,
        // ComPagination,
        SelectAddr
    },
    created () {
        // setTimeout(() => {
        //     // 91520402MA6DNQRQ07
        //     this.formData.unitCode = '124346446442422424'
        //     this.unitCodeBlur('124346446442422424')
        //     // console.log('options.taxpayerType', this.options.taxpayerType)
        // }, 1000)
        // 外包方类型、纳税人类别
        this.getTypeData()
        ;(async () => {
            await this.getTenderData() // 获取招标基础信息
            this.getPackage() // 获取包件信息
            // this.formData.applyId = this.tenderId
            // const random19Num = await this.random19Num()
            // this.formData.billId = random19Num
        })()
    },
    mounted () {
        // 保存所有tabName
        const arr = ['baseInfo', 'package', 'enterprise', 'quaInfo', 'manager', 'attach']
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight(arr)
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }
            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const itemTop = document.getElementById(item)?.offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item)?.offsetTop
                return itemTop
            })
        })
    },
    beforeDestroy () {
        this.$notify.closeAll()
    },
    methods: {
        diaLogSubmit () {
            this.dialogVisible = false
            this.row.certificateGrade = [...this.treeCheckSet].join(',')
        },
        treeCheckChange (data, isCheck) {
            if (isCheck) {
                this.treeCheckSet.add(data.kvValue)
            } else {
                this.treeCheckSet.delete(data.kvValue)
            }
        },
        async loadNode (node, resolve) {
            if (node.level === 0) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: 0
                })
                return resolve(res)
            }
            if (node.level >= 1) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: node.data.kvId
                })
                return resolve(res)
            }
        },
        onSelect (row) {
            // 需要刷新 主营范围/证书等级 接口
            this.treeKey += 1
            // 弹窗后需要改变，所以保存
            this.row = row
            this.dialogVisible = true
            console.log('row.certificateType', row.certificateType)
            this.dialogTitle =
                row.certificateType === '营业执照' ? '请选择主营范围' : '请选择资质等级'
        },
        // 资质信息 证书类型切换
        certificateTypeChange (val, row) {
            // 证书类型，安全许可证，不能选择日期结束时间，根据有效期开始时间加3年
            // if (val === '安全生产许可证') {
            //     row.endTime = new Date(
            //         Date.parse(new Date(row.startTime)) + 31536000000 * 3 + 86400000
            //     )
            // }
            // 营业执照时，证书编号为信用代码
            if (val === '营业执照') {
                row.certificateNo = this.formData.unitCode
            }
        },
        changeIsAbroad (val) {
            // 是境外单位纳税类别可以选择小型
            if (val === 1 && this.formData.taxpayerType === '其他') {
                this.formData.taxpayerType = ''
            }
        },
        forever (row, name) {
            row[name] = '9999-12-30'
        },
        timeBlur (row) {
            if (new Date(row.startTime).getTime() > new Date(row.endTime).getTime()) {
                row.endTime = null
            }
        },
        deleteTableRow (tableName) {
            if (this.selection[tableName].length === 0) return
            this.selection[tableName].forEach(item => {
                // 前端删除
                const deleteIndex = this[tableName].findIndex(
                    item2 => (item.recordId = item2.recordId)
                )
                this[tableName].splice(deleteIndex, 1)
            })
        },
        selectionChange (tabaleName, selection) {
            this.selection[tabaleName] = selection
        },
        // 资质信息增加
        async quaInfoAdd (table) {
            table.push({
                billId: '',
                changeType: 1,
                contractAmount: 0,
                contractName: '',
                endTime: '',
                fileName: '',
                filePath: '',
                gmtCreate: '',
                gmtModified: '',
                personInCharge: '',
                projectName: '',
                recordId: await this.uidBuilder({
                    num: 1
                }),
                startTime: '',
                witness: '',
                witnessPhone: '',
                workContent: '',
                frontState: 1
            })
        },
        // 历史业绩增加
        async enterpriseAdd (table) {
            table.push({
                billId: '',
                changeType: 1,
                contractAmount: 0,
                contractName: '',
                endTime: '',
                fileName: '',
                filePath: '',
                gmtCreate: '',
                gmtModified: '',
                personInCharge: '',
                projectName: '',
                recordId: await this.uidBuilder({
                    num: 1
                }),
                startTime: '',
                witness: '',
                witnessPhone: '',
                workContent: '',
                frontState: 1
            })
        },
        //获取分包商类型数据
        getTypeData () {
            call.getCredentialTree({ name: '外包方类型', id: '0' }).then(res => {
                let id = ''
                // 获取想要的类型id
                res.map(item => {
                    if (item.kvKey == '分包商') {
                        id = item.kvId
                    }
                })
                call.getCredentialTree({ name: '外包方类型', id: id }).then(res => {
                    this.typeList = res
                    console.log('this.typeList', this.typeList)
                })
                call.getCredential('纳税类别').then(res => {
                    this.payTaxesTypeList = res
                    console.log('this.payTaxesTypeList', this.payTaxesTypeList)
                })
            })
        },
        async submit () {
            // 基础信息验证
            this.$refs.ruleForm.validate(valid => {
                if (!valid) {
                    this.onChangeTab({ name: 'baseInfo' })
                    return
                }
            })
            // 包件验证
            console.log('this.selection.packageTableData', this.selection.packageTableData)
            if (
                this.selection.packageTableData === undefined ||
                this.selection.packageTableData?.length === 0
            ) {
                this.clientPop('err', '请选择包件')
                return
            }
            // 基础信息
            this.formData.outsourceType =
                this.formData.outsourceType.length !== 0
                    ? this.formData.outsourceType.join(',')
                    : ''
            const promise1 = await equipmentProcurementRequest.erollCreate(this.formData)
            // 添加billId
            this.quaInfoTableData.forEach(item => {
                item.billId = promise1
            })
            this.enterpriseTableData.forEach(item => {
                item.billId = promise1
            })
            // 处理资质信息有效期
            this.quaInfoTableData.forEach(item => {
                if (item.validate.constructor === Array) {
                    item.validate = item.validate.join(',')
                }
            })
            // 资质信息
            const promise2 = equipmentProcurementRequest.certificateCreate(this.quaInfoTableData)
            // 历史业绩
            const promise3 = equipmentProcurementRequest.achievementHistoryCreate(
                this.enterpriseTableData
            )
            // 包件信息
            const promise4 = equipmentProcurementRequest.erollPackageCreate(
                this.selection.packageTableData
            )
            Promise.all([promise1, promise2, promise3, promise4]).then(() => {
                this.clientPop('suc', '保存成功')
            })
        },
        bytesToSize (byte) {
            return bytesToSize(byte)
        },
        async delFile (row) {
            await ossRequest.deleterByRelationId({ relationId: row.recordId }).then(() => {
                row.fileName = ''
                row.filePath = ''
                row.fileSize = ''
            })
        },
        // 上传成功后
        handleAvatarSuccess (response, file, fileList, row) {
            const res = response.data[0]
            row.fileName = res.originalObjectName
            row.filePath = res.objectPath
            row.fileSize = res.objectSize
            row.upTime = res.gmtCreate
            this.$refs.enterpriseUpload.clearFiles() //上传成功之后清除历史记录
        },
        async uidBuilder (params, type = 'str') {
            let temp = []
            await uidBuilder(params).then(res => {
                temp = type === 'str' ? res[0] : res
            })
            return temp
        },
        // 上传前
        async beforeAvatarUpload (file) {
            const isLt2M = file.size / 1024 / 1024 < 20
            if (!isLt2M) {
                this.clientPop('err', '上传文件大小不能超过 20MB！')
            }
            return isLt2M
        },
        getObjectByRelationId () {
            if (!this.relationId) return
            return ossRequest.getObjectByRelationId({ relationId: this.relationId }).then(res => {
                this.attachTableData = res
                this.total = res.length
            })
        },
        checkCode (creditCode) {
            function checkCreditCode (creditCode) {
                const secondarray = [
                    '0',
                    '1',
                    '2',
                    '3',
                    '4',
                    '5',
                    '6',
                    '7',
                    '8',
                    '9',
                    'A',
                    'B',
                    'C',
                    'D',
                    'E',
                    'F',
                    'G',
                    'H',
                    'J',
                    'K',
                    'L',
                    'M',
                    'N',
                    'P',
                    'Q',
                    'R',
                    'T',
                    'U',
                    'W',
                    'X',
                    'Y'
                ]
                //加权因子数值
                const secondkeys = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28]
                //将信用代码中小写字母转成大写
                if (creditCode.length != 18) {
                    return false
                }
                var reg = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/
                if (!reg.test(creditCode)) {
                    return false
                }

                const parityBit = getParityBit(creditCode, secondkeys, secondarray)
                if (parityBit < 0) {
                    return false
                } else {
                    return creditCode.slice(17) === secondarray[parityBit]
                }
            }

            function getParityBit (code, secondkeys, secondarray) {
                let sum = 0
                let i
                for (i = 0; i < 17; ++i) {
                    let codeIndex = secondarray.indexOf(code[i])
                    if (codeIndex === -1) {
                        return -1
                    }
                    sum += codeIndex * secondkeys[i]
                }
                i = 31 - (sum % 31)
                return i == 31 ? 0 : i
            }
            return checkCreditCode(creditCode)
        },
        onblur (val) {
            console.log(val)
        },
        unitCodeBlur (creditCode) {
            if (creditCode === '') return
            if (!this.checkCode(creditCode)) {
                this.clientPop('err', '统一信用代码不合格')
                return
            }
            openBiddingRequest.creditcodeAllInfo(creditCode).then(res => {
                if (res.data === null) {
                    this.clientPop('info', '系统外包方库中的分包商库不存在，是否新增', () => {
                        this.unitCodeState = false
                        // 库外外包方纳税类别为其他
                        // this.formData.taxpayerType = '其他'
                    })
                } else {
                    // 基本信息
                    this.unitCodeState = true
                    this.unitCodeState2 = false
                    this.formData.unitName = res.subcontractor.orgName
                    this.formData.outsourceType = res.subcontractor.subcontractorTypeKey.split(',')
                    this.formData.outsourceType.forEach((item, index) => {
                        if (item === '施工合作') {
                            this.formData.outsourceType.splice(index, 1)
                            this.formData.outsourceType.push('施工分包')
                        }
                    })
                    this.formData.registerCaptial = res.subcontractor.registerCapital
                    this.formData.legalRepresentative = res.subcontractor.deputy
                    this.formData.registerAddress = res.subcontractor.addressDetail
                    this.formData.taxpayerType = res.subcontractor.taxTypeKey //
                    this.formData.fax = res.subcontractor.fax
                    this.formData.telephone = res.subcontractor.contactTel
                    this.formData.zipCode = res.subcontractor.postCode
                    this.formData.email = res.subcontractor.email
                    this.formData.qualificationLevelName = res.qualificationLevelName
                    this.formData.isAbroad = res.subcontractor.isAbroadUnit
                    // 资质信息
                    if (res.qualificationinfoList.length !== 0) {
                        res.qualificationinfoList.map(async (item, index) => {
                            this.$set(this.quaInfoTableData, index, {
                                billId: '',
                                certificateGrade: '',
                                certificateNo: '',
                                certificateType: '',
                                changeType: 1,
                                fileName: '',
                                filePath: '',
                                fileSize: 0,
                                gmtCreate: '',
                                gmtModified: '',
                                recordId: '',
                                upTime: '',
                                upUser: '',
                                upUserId: '',
                                validate: ''
                            })
                            this.quaInfoTableData[index].certificateGrade =
                                item.qualificationLevelName
                            this.quaInfoTableData[index].certificateNo = item.certNo
                            this.quaInfoTableData[index].certificateType = item.certTypeValue
                            this.quaInfoTableData[index].fileName = item.fileName
                            this.quaInfoTableData[index].fileSize = item.size
                            this.quaInfoTableData[index].upTime = item.gmtCreate
                            this.quaInfoTableData[index].filePath = item.dialogImage
                            // this.quaInfoTableData[index].validate = [item.startDate, item.endDate]
                            this.quaInfoTableData[index].startTime = item.startDate
                            this.quaInfoTableData[index].endTime = item.endDate
                            this.quaInfoTableData[index].recordId = await this.uidBuilder({
                                num: 1
                            })
                        })
                    }
                    // 历史业绩
                    if (res.performanceList.length !== 0) {
                        res.performanceList.map(async (item, index) => {
                            this.$set(this.enterpriseTableData, index, {
                                billId: '',
                                changeType: 1,
                                contractAmount: 0,
                                contractName: '',
                                endTime: '',
                                fileName: '',
                                filePath: '',
                                gmtCreate: '',
                                gmtModified: '',
                                personInCharge: '',
                                projectName: '',
                                recordId: '',
                                startTime: '',
                                witness: '',
                                witnessPhone: '',
                                workContent: ''
                            })
                            this.enterpriseTableData[index].contractAmount = item.contractAmount
                            this.enterpriseTableData[index].contractName = item.contractName
                            this.enterpriseTableData[index].endTime = item.endDate
                            this.enterpriseTableData[index].personInCharge = item.projectLeader
                            this.enterpriseTableData[index].projectName = item.projectName
                            this.enterpriseTableData[index].startTime = item.startDate
                            this.enterpriseTableData[index].witness = item.witnessName
                            this.enterpriseTableData[index].witnessPhone = item.witnessTel
                            this.enterpriseTableData[index].workContent = item.workContect
                            this.enterpriseTableData[index].fileName = item.fileName
                            this.enterpriseTableData[index].recordId = await this.uidBuilder({
                                num: 1
                            })
                        })
                    }
                    console.log('this.formData', this.formData)
                }
            })
            console.log('历史业绩', this.enterpriseTableData)
        },
        async random19Num () {
            let temp = ''
            await uidBuilder({ num: 1 }).then(res => {
                temp = res[0]
            })
            return temp
        },
        findById () {},
        onSuccess1 (response, file, fileList, recordId) {
            const index = this.enterpriseTableData.findIndex(value => {
                return value.recordId === recordId
            })
            // console.log('index', index)
            this.$set(this.enterpriseTableData[index], 'ifUpload', true)
            ossRequest.getObjectByRelationId({ relationId: recordId }).then(res => {
                this.$set(this.enterpriseTableData[index], 'filePath', res[0].objectPath)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onSuccess2 (response, file, fileList, recordId) {
            const index = this.quaInfoTableData.findIndex(value => {
                return value.recordId === recordId
            })
            ossRequest.getObjectByRelationId({ relationId: recordId }).then(res => {
                this.$set(this.quaInfoTableData[index], 'fileName', res[0].objectName)
                this.$set(this.quaInfoTableData[index], 'fileSize', res[0].objectSize)
                this.$set(
                    this.quaInfoTableData[index],
                    'upTime',
                    res[0].gmtCreate.slice(0, res[0].gmtCreate.indexOf(' '))
                )
                this.$set(this.quaInfoTableData[index], 'filePath', res[0].objectPath)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onSuccess3 (response, file, fileList, recordId) {
            const index = this.managerTableData.findIndex(value => {
                return value.recordId === recordId
            })
            // console.log('index', index)
            this.$set(this.managerTableData[index], 'ifUpload', true)
            ossRequest.getObjectByRelationId({ relationId: recordId }).then(res => {
                this.$set(this.managerTableData[index], 'filePath', res[0].objectPath)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
        },
        onSuccess4 (response, file, fileList, id) {
            const index = this.attachTableData.findIndex(value => {
                return value.id === id
            })
            ossRequest.getObjectByRelationId({ relationId: this.formData.billId }).then(res => {
                const mapRes = {}
                mapRes.fileName = res[0].objectName
                mapRes.filePath = res[0].objectPath
                mapRes.size = res[0].objectSize
                mapRes.type = this.attachTableData[index].type
                mapRes.upLoadTime = res[0].gmtCreate.slice(0, res[0].gmtCreate.indexOf(' '))
                mapRes.recordId = res[0].recordId
                // 用于删除
                this.$set(this.attachTableData, index, mapRes)
            })
            this.$message({
                showClose: true,
                type: 'success',
                message: '上传成功'
            })
            console.log('fileList', fileList)
        },
        onError () {
            this.$message({
                showClose: true,
                type: 'error',
                message: '上传失败'
            })
        },
        async tableDel (key) {
            for (let i = 0; i < this.selection[key].length; i++) {
                const tableData = key + 'TableData'
                const index = this[tableData].findIndex(value2 => {
                    return value2.recordId === value2.recordId
                })
                //后端删除
                if (key === 'enterprise' || key === 'manager') {
                    // 企业主要业绩、企业主要管理人（没有fileName,是我自己加的ifUpload）
                    if (!this[tableData][index].ifUpload) {
                        //前端删除
                        this[tableData].splice(index, 1)
                        return
                    }
                    await ossRequest
                        .deleterRecordId({ recordId: this[tableData][index].recordId })
                        .then(() => {
                            //前端删除
                            this[tableData].splice(index, 1)
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '删除成功'
                            })
                        })
                        .catch(() => {
                            return
                        })
                    // 资质信息、附件信息
                } else {
                    if (!this[tableData][index].fileName) {
                        //前端删除
                        this[tableData].splice(index, 1)
                        return
                    }
                    await ossRequest
                        .deleterRecordId({ recordId: this[tableData][index].recordId })
                        .then(() => {
                            //前端删除
                            this[tableData].splice(index, 1)
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '删除成功'
                            })
                        })
                }
            }
        },
        // selectionChange (key, e) {
        //     this.selection[key] = e
        // },
        // eslint-disable-next-line no-unused-vars
        cellClick (row, column, cell, event) {
            if (column.label === '招标编号') {
                this.$router.push({
                    path: './biddingApplicationShow',
                    query: { tenderId: row.billId }
                })
            }
        },
        handleSelectionChange (e, event) {
            console.log(e)
            console.log('$event', event)
        },
        enterpriseAddInputBlur () {
            if (this.formData.contractName) {
                enrollRequest.achievementCreate(this.formData).then(res => {
                    console.log(res)
                    // 增加包件id，用于编辑
                    // this.formData.dtlId = res
                })
            }
        },
        // async enterpriseAdd () {
        //     const random19Num = await this.random19Num()
        //     this.enterpriseTableData.unshift({
        //         contractName: '',
        //         projectName: '',
        //         contractAmount: '',
        //         workContent: '',
        //         startTime: '',
        //         endTime: '',
        //         personInCharge: '',
        //         witness: '',
        //         witnessPhone: '',
        //         safetyEvaluation: '',
        //         proveFile: '',
        //         addData: 1, //前端自定义判断是否是新增数据
        //         recordId: random19Num
        //     })
        // },
        // async quaInfoAdd () {
        //     const random19Num = await this.random19Num()
        //     this.quaInfoTableData.unshift({
        //         certificateType: '',
        //         certificateNo: '',
        //         certificateGrade: '',
        //         validateStart: '',
        //         validateEnd: '',
        //         addData: 1, //前端自定义判断是否是新增数据
        //         recordId: random19Num
        //     })
        // },
        async managerAdd () {
            const random19Num = await this.random19Num()
            this.managerTableData.unshift({
                type: '',
                name: '',
                idCardNo: '',
                certNo: '',
                phone: '',
                endTime: '',
                addData: 1, //前端自定义判断是否是新增数据
                recordId: random19Num
            })
        },
        attachAdd () {
            this.attachTableData.unshift({
                fileName: '',
                filePath: '',
                size: '',
                type: '',
                upLoadTime: '',
                addData: 1
                // recordId: this.formData.billId
            })
            // this.$refs.upload4?.clearFiles()
        },
        async getTenderData () {
            await equipmentProcurementRequest.applyGetById({ id: this.tenderId }).then(res => {
                this.formData.projectName = res.tenderName
                this.formData.tenderApplyId = res.billId
                this.formData.tenderApplyNo = res.billNo
                this.formData.applyUnit = res.tenderUser
                this.formData.tenderType = res.tenderClass
                this.formData.enrollTime = this.getNowDate()
            })
        },
        getPackage () {
            equipmentProcurementRequest
                .packageListByEntity({
                    limit: 20,
                    page: 1,
                    tenderApplyId: this.tenderId
                })
                .then(async res => {
                    if (res.length === 0) return
                    this.packageTableData = res
                    this.packageTableData.forEach(item => {
                        item.changeType = 1
                    })
                    res.forEach(item => {
                        this.formData.packageName += item.name + '，'
                    })
                    this.formData.packageName = this.formData.packageName.substr(
                        0,
                        this.formData.packageName.length - 1
                    )
                    // 前端显示的分包商
                    // this.pagination.total = res.totalCount || res.length
                })
        },
        onChangeTab (e) {
            const height = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight (arr) {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById(arr[length - 1] + 'Con')) {
                    const lastConHeight = document.getElementById(
                        arr[length - 1] + 'Con'
                    )?.offsetHeight
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        delData () {
            // bidNoticeRequest.batchDelete([this.billId]).then(res => {
            //     this.$message({
            //         showClose: true,
            //         type: 'success',
            //         message: res.message
            //     })
            //     this.$router.push({
            //         path: './biddingApplicationEdit',
            //         query: { billid: this.tenderId, seat: 'reg' }
            //     })
            // })
        },
        // getData () {
        //     bidNoticeRequest.findById(this.billId).then(res => {
        //         this.formData = res
        //     })
        // },
        showBidding () {
            if (!this.tenderId) return // 前期需求可切换，现在不需要
            this.$notify.closeAll()
            this.$notify({
                title: '查看招标详情',
                dangerouslyUseHTMLString: true,
                message: `正式环境：客户端打开新页面<br>
              测试环境：手动打开新页面<br>
              <el-input cols="35" rows="10">http://localhost:8080/biddingApplicationShow?tenderId=${this.tenderId}</el-input>
              `,
                duration: 0
            })
            // this.$router.push({
            //     path: './biddingApplicationShow',
            //     query: { tenderId: this.tenderId }
            // })
        },
        // submit () {
        //     console.log('asdasd', this.enterpriseTableData)
        //     // 处理地址
        //     // 地址
        //     const temp = JSON.parse(this.formData.addressCode)
        //     const address = this.formData.addressCode !== '' ? temp.address.join(',') : ''
        //     const code = this.formData.addressCode !== '' ? temp.code.join(',') : ''
        //     const detail = temp.detail
        //     // 固定工作地址
        //     const temp2 = JSON.parse(this.formData.fixAddressCode)
        //     const address2 = this.formData.fixAddress !== '' ? temp2.address.join(',') : ''
        //     const code2 = this.formData.fixAddress !== '' ? temp2.code.join(',') : ''
        //     const detail2 = temp2.detail
        //     this.formData.address = address
        //     this.formData.addressCode = code
        //     this.formData.addressDetail = detail
        //     this.formData.fixAddress = address2
        //     this.formData.fixAddressCode = code2
        //     this.formData.fixAddressDetail = detail2
        //     // 企业主要业绩、资质信息、企业主要管理人、附件信息
        //     this.formData.history = this.enterpriseTableData
        //     this.formData.applyQualifications = this.quaInfoTableData
        //     this.formData.applyPersonnels = this.managerTableData
        //     this.formData.attachments = this.attachTableData
        //     this.formData.attachments.forEach(value => {
        //         delete value.recordId
        //     })
        //     console.log('formData', this.formData)
        //     // 发送请求
        //     enrollRequest.create(this.formData).then(() => {
        //         this.$message({
        //             showClose: true,
        //             type: 'success',
        //             message: '提交成功'
        //         })
        //         // 重置地址
        //         this.formData.addressCode = ''
        //         this.formData.fixAddressCode = ''
        //     })
        //     // bidNoticeRequest.update(this.formData).then(res => {
        //     //     // this.dialogVisible = false
        //     //     this.$message({
        //     //         showClose: true,
        //     //         type: 'success',
        //     //         message: res.message
        //     //     })
        //     //     this.$router.push({
        //     //         path: './biddingApplicationEdit',
        //     //         query: { billid: this.tenderId, seat: 'reg' }
        //     //     })
        //     // })
        // },
        getNowDate () {
            // 个位数前补0
            const zeroFill = function (num) {
                if (parseInt(num) < 10) {
                    num = '0' + num
                }
                return num
            }
            let nowtime = new Date()
            nowtime =
                zeroFill(nowtime.getFullYear()) +
                '-' +
                zeroFill(nowtime.getMonth() + 1) +
                '-' +
                zeroFill(nowtime.getDate())
            return nowtime
            // this.$set(this.formData, 'applyTime', nowtime)
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        reset () {
            this.clientPop('info', '确认重置？重置后会将数据全部清空，请谨慎操作！', () => {
                this.formData = {
                    abandondeExplain: '',
                    abandonedReason: '',
                    abandonedTime: '',
                    abandonedUser: '',
                    abandonedUserId: '',
                    applyUnit: '',
                    applyUnitId: '',
                    billId: '',
                    email: '',
                    enrollTime: '',
                    fax: '',
                    fixedTelephone: '',
                    gmtCreate: '',
                    gmtModified: '',
                    legalRepresentative: '',
                    nullifyCreated: '',
                    nullifyCreator: '',
                    nullifyCreatorId: '',
                    nullifyDescription: '',
                    nullifyReason: '',
                    orgId: '',
                    orgName: '',
                    outsourceType: '',
                    packageIds: '',
                    packageName: '',
                    projectName: '',
                    proxyUser: '',
                    registerAddress: '',
                    registerCaptial: 0,
                    state: 0,
                    taxpayerType: '',
                    telephone: '',
                    tenderApplyId: '',
                    tenderApplyNo: '',
                    tenderType: 0,
                    unitCode: '',
                    unitName: '',
                    workId: '',
                    zipCode: ''
                }
                this.enterpriseTableData = []
                this.quaInfoTableData = []
                this.enterpriseTableData = []
                this.getTenderData()
                this.getPackage()
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.title {
    position: absolute;
    top: 10px;
    right: 30px;
}
::v-deep.require::first-letter {
    color: red !important;
}
.buttons {
    display: flex;
    justify-content: center;
    .el-button {
        padding: 15px 50px;
    }
}
.form {
    margin-top: 10px;
}

.e-table {
    background: #fff;

    /* .top {
  .left {
    padding: 20px;
    padding-top: 0px;
  }
} */
}

.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 滚动条 */
.e-form {
    ::-webkit-scrollbar {
        width: 12px;
        height: 15px;
    }

    ::-webkit-scrollbar-track {
        -webkit-border-radius: 10px;
        border-radius: 10px;
        background: #f6f7f9;
    }

    ::-webkit-scrollbar-thumb {
        -webkit-border-radius: 10px;
        border-radius: 10px;
        background: rgba(204, 204, 204, 0.8);
    }
    ::-webkit-scrollbar-thumb:window-inactive {
        background: rgba(204, 204, 204, 0.4);
    }
}

// 附件栏
.affix {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .right {
        display: flex;
        align-items: center;
        i {
            margin-left: 10px;
        }
    }
}
</style>
